package pseudoAssemblerCompiler.twopassassembler.view.secondpass;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import pseudoAssemblerCompiler.twopassassembler.view.common.IView;
import pseudoAssemblerCompiler.twopassassembler.view.util.CTabFolderContainer;


/**
 * Контейнер содержащий представления второго прохода
 * @author Администратор
 *
 */
public class SecondPass implements IView {

    /**
     * Основной контейнер представления второго прохода
     */
    private Composite _composite;
    
    /**
     * Вспомогательная таблица
     */
    private Composite _referenceTableComposite;
    
    /**
     * Таблица символических имён
     */
    private Composite _symbolicNamesTableComposite;

    public Composite get_composite() {
        return _composite;
    }

    public Composite get_referenceTableComposite() {
        return _referenceTableComposite;
    }

    public Composite get_symbolicNamesTableComposite() {
        return _symbolicNamesTableComposite;
    }

    public SecondPass(Composite aParent) {
        CTabFolderContainer secondPassTabFolder = new CTabFolderContainer(aParent);
        _composite = new Composite(secondPassTabFolder.createCTabItem("Второй проход"), SWT.NONE);
        _referenceTableComposite = new Composite(_composite, SWT.NONE);
        _symbolicNamesTableComposite = new Composite(_composite, SWT.NONE);
    }
    
    /**
     * Располагаем элементы в определённом порядке
     */
    protected void layouts() {
        FormData data;

        data = new FormData();
        data.top = new FormAttachment(0, 0); // Attach to top
        data.left = new FormAttachment(0, 0); // Attach halfway across
        data.bottom = new FormAttachment(100, 0); // Attach to bottom
        data.right = new FormAttachment(100, 0);
        _composite.setLayout(new FormLayout());
        _composite.setLayoutData(data);
        
        //Sash - переплёт
        data = new FormData();
        data.top = new FormAttachment(0, 10); // Attach to top
        data.right = new FormAttachment(100, 0); 
        data.bottom = new FormAttachment(50, 0); // Attach to bottom
        data.left = new FormAttachment(0, 0); // Attach halfway across
        _referenceTableComposite.setLayout(new FormLayout());
        _referenceTableComposite.setLayoutData(data);
        
        //Sash - переплёт
        data = new FormData();
        data.top = new FormAttachment(_referenceTableComposite, 20); // Attach to top
        data.right = new FormAttachment(100, 0); 
        data.bottom = new FormAttachment(100, 0); // Attach to bottom
        data.left = new FormAttachment(0, 0); // Attach halfway across
        _symbolicNamesTableComposite.setLayout(new FormLayout());
        _symbolicNamesTableComposite.setLayoutData(data);
    }

    @Override
    public void setLayoutData(Object layoutData) {
        _composite.setLayoutData(layoutData);
    }

    @Override
    public void show() {
        layouts();
    }

    @Override
    public Composite getComposite() {
        return _composite;  //this method do nothing
    }

    @Override
    public void setController(Object controller) {
        //this method do nothing
    }
}
